package com.ys.controller;

import com.ys.common.R;
import com.ys.order.OrderAPI;
import com.ys.pojo.TradeOrder;
import com.ys.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
@RequestMapping("order")
public class OrderController implements OrderAPI {
    @Autowired
    private OrderService orderService;
    @Override
    @PostMapping("/confirmOrder")
    public R confirmOrder(TradeOrder order) {
        order.setUserId(345963634385633280L);
        order.setAddress("郑州");
        order.setGoodsId(345959443973935104L);
        order.setGoodsNumber(1);
        order.setGoodsPrice(new BigDecimal(5000.00));
        order.setOrderAmount(new BigDecimal(5000.00));
        order.setCouponId(345988230098857984L);
        order.setCouponPaid(new BigDecimal(20.00));
        order.setMoneyPaid(new BigDecimal(100.00));
        order.setPayAmount(new BigDecimal(4880.00));
        return orderService.confirmOrder(order);
    }
    @RequestMapping("test")
    public R test(){
        return R.ok().message("测试成功");
    }
}
